<template>
  <div class="dashboard-editor-container">
    <!-- <github-corner class="github-corner"  margin-top:12px;  /> -->

    <el-row style="width: 86.3%; top: 6px; z-index: 999; position: fixed">
      <el-col :span="20" class="card-box">
        <!-- <i class="el-icon-s-data" /><span style="font-weight:600;color:#666;margin-right: 450px;margin-left: 5px;">
          销售总览
        </span> -->
        <el-cascader
          class="region"
          v-model="salesGrade"
          placeholder="选择店铺分组"
          :options="cascadeList"
          :props="{ checkStrictly: true }"
          @change="handleChange"
          style="width: 300px; height: 30px"
        >
        </el-cascader>
      </el-col>
      <!-- <el-col :span="12" style="background-color: #f5f5f5; height: 30px">
        <nav id="navbar">
          <ul>
            <li :class="{ active: isActiveSection(1) }">
              <a href="#section1" @click="scrollToSection(1)">MTD</a>
            </li>
            <li :class="{ active: isActiveSection(2) }">
              <a href="#section2" @click="scrollToSection(2)">QTD</a>
            </li>
            <li :class="{ active: isActiveSection(3) }">
              <a href="#section3" @click="scrollToSection(3)">YTD</a>
            </li>
            <li :class="{ active: isActiveSection(4) }">
              <a href="#section4" @click="scrollToSection(4)">整体销售趋势</a>
            </li>
            <li :class="{ active: isActiveSection(5) }">
              <a href="#section5" @click="scrollToSection(5)">品牌销售额</a>
            </li>

            <li :class="{ active: isActiveSection(6) }">
              <a href="#section6" @click="scrollToSection(6)">渠道销售追踪</a>
            </li>
            
          </ul>
        </nav>
      </el-col> -->
      <el-col :span="4">
        <el-radio-group v-model="dateType" size="small">
          <el-radio-button
            v-for="(item, index) in typeArr"
            :key="index"
            :label="item.value"
            >{{ item.label }}</el-radio-button
          >
        </el-radio-group>
      </el-col>
      <!--<el-col :span="7">
         <date
          v-model="valueTime"
          :type.sync="groupType"
          @handleChangeTime="handleChangeTime($event)"
        ></date>
      </el-col> -->
    </el-row>

    <!-- <section id="section1">
      <el-row :gutter="10" class="mb8" style="padding: 32px 0">
        <el-col :span="6">
          <el-card>
            <div slot="header">
              <span
                ><i class="el-icon-pie-chart"></i>
                {{ query.salesGrade + " " }}本月完成率</span
              >
            </div>
            <card
              :id="'monthly'"
              :chartData="echartDatamonthly"
              height="205px"
              width="100%"
            />

            <div class="content">
              <progressMonthly />
            </div>
          </el-card>
        </el-col>
        <el-col :span="18">
          <el-card>
            <panel-group
              @handleSetLineChartData="handleSetLineChartData"
              :biNumberItem="biNumberItem"
            />
          </el-card>
        </el-col>
      </el-row>
    </section> -->
    <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
      <el-tab-pane label="经营概况" name="0">
        <section id="section1">
          <!-- margin-bottom: 32px-->
          <el-row :gutter="10" style="padding: 32px 0">
            <el-col :span="6">
              <el-card>
                <div slot="header">
                  <span
                    ><i class="el-icon-collection"></i>
                    {{ query.salesGrade + " " }}昨日经营概况</span
                  >
                </div>

                <div class="nomargin">昨日销售额</div>
                <div class="content" style="font-weight: bold; font-size: 20px">
                  {{ dateList.saleAmount }}万
                </div>
                <div class="content" style="font-size: 14px">
                  同比：{{ dateList.saleAmountYoy }}%
                </div>
                <div class="content" style="font-size: 14px">
                  环比：{{ dateList.saleAmountChain }}%
                </div>
                <div class="content" style="margin: 10px 0">
                  <progressYear
                    :progressValue="dateList.targetCompletionRate"
                  />
                </div>
                <div class="content">
                  销售目标：{{ dateList.salesTarget }}万
                </div>
                <div class="nomargin">
                  总店铺运营数：{{ dateList.shopCount }}家
                </div>
              </el-card>
            </el-col>
            <el-col :span="10">
              <el-card>
                <!-- <div slot="header">
              <span 
                ><i class="el-icon-collection"></i> 本月完成率</span
              >
            </div> -->
                <panel-group-date
                  @handleSetLineChartData="handleSetLineChartData"
                  :biNumberItem="dateList"
                />
              </el-card>
            </el-col>
            <el-col :span="8">
              <el-card>
                <div slot="header">
                  <span
                    ><i class="el-icon-collection"></i
                    >{{ query.salesGrade + " " }} 昨日平台转化</span
                  >
                </div>
                <funnelDate
                  :id="'funnelDateList'"
                  :chartData="funnelDateList"
                />

                <!-- <card
              :id="'quarterly'"
              :chartData="echartDataquarterly"
              height="205px"
              width="100%"
            />

            <div class="content">
              <progressYear :progressValue="biNumberItem.quarterlyProgress" />
            </div> -->
              </el-card>
            </el-col>
          </el-row>
        </section>

        <section id="section2">
          <!-- margin-bottom: 32px-->
          <el-row :gutter="10" style="padding: 32px 0">
            <el-col :span="6">
              <el-card>
                <div slot="header">
                  <span
                    ><i class="el-icon-collection"></i>
                    {{ query.salesGrade + " " }}本周经营概况</span
                  >
                </div>

                <div class="nomargin">本周销售额</div>
                <div class="content" style="font-weight: bold; font-size: 20px">
                  {{ weekList.saleAmount }}万
                </div>
                <div class="content" style="font-size: 14px">
                  同比：{{ weekList.saleAmountYoy }}%
                </div>
                <div class="content" style="font-size: 14px">
                  环比：{{ weekList.saleAmountChain }}%
                </div>
                <div class="content" style="margin: 10px 0">
                  <progressYear
                    :progressValue="weekList.targetCompletionRate"
                  />
                </div>
                <div class="content">
                  销售目标：{{ weekList.salesTarget }}万
                </div>
                <div class="nomargin">
                  总店铺运营数：{{ weekList.shopCount }}家
                </div>
              </el-card>
            </el-col>
            <el-col :span="10">
              <el-card>
                <!-- <div slot="header">
              <span 
                ><i class="el-icon-collection"></i> 本月完成率</span
              >
            </div> -->
                <panel-group-week
                  @handleSetLineChartData="handleSetLineChartData"
                  :biNumberItem="weekList"
                />
              </el-card>
            </el-col>
            <el-col :span="8">
              <el-card>
                <div slot="header">
                  <span
                    ><i class="el-icon-collection"></i
                    >{{ query.salesGrade + " " }} 本周平台转化</span
                  >
                </div>
                <funnelDate
                  :id="'funnelWeekList'"
                  :chartData="funnelYearList"
                  style="text-align: center"
                />
                <!-- <funnelWeek :chartData="funnelWeekList" /> -->

                <!-- <card
              :id="'quarterly'"
              :chartData="echartDataquarterly"
              height="205px"
              width="100%"
            />

            <div class="content">
              <progressYear :progressValue="biNumberItem.quarterlyProgress" />
            </div> -->
              </el-card>
            </el-col>
          </el-row>
        </section>

        <!-- <section id="section3">
      <el-row :gutter="10" style="padding: 32px 0">
        <el-col :span="6">
          <el-card>
            <div slot="header">
              <span
                ><i class="el-icon-collection"></i>
                {{ query.salesGrade + " " }}年度完成率</span
              >
            </div>

            <card
              :id="'year'"
              :chartData="echartData"
              height="205px"
              width="100%"
            />

           
          </el-card>
        </el-col>
        <el-col :span="18">
          <el-card>
            <PanelGroupII
              @handleSetLineChartData="handleSetLineChartData"
              :biNumberItem="biNumberItem"
            />
          </el-card>
        </el-col>
      </el-row>
    </section> -->
        <section id="section3">
          <el-row :gutter="10" style="padding: 32px 0">
            <el-col :span="6">
              <el-card>
                <div slot="header">
                  <span
                    ><i class="el-icon-collection"></i>
                    {{ query.salesGrade + " " }}运营监控</span
                  >
                </div>

                <div class="nomargin">{{ dateType | state1 }}销售额</div>
                <div class="content" style="font-weight: bold; font-size: 20px">
                  {{ biNumberItem.saleAmount }}万
                </div>
                <div class="content" style="font-size: 14px">
                  同比：{{ biNumberItem.saleAmountYoy }}%
                </div>
                <div class="content" style="font-size: 14px">
                  环比：{{ biNumberItem.saleAmountChain }}%
                </div>
                <div class="content" style="margin: 10px 0">
                  <progressYear
                    :progressValue="biNumberItem.targetCompletionRate"
                  />
                </div>
                <div class="content">
                  销售目标：{{ biNumberItem.salesTarget }}万
                </div>
                <div class="nomargin">
                  总店铺运营数：{{ biNumberItem.shopCount }}家
                </div>
              </el-card>
            </el-col>
            <el-col :span="18">
              <el-card>
                <panel-group
                  @handleSetLineChartData="handleSetLineChartData"
                  :biNumberItem="biNumberItem"
                />
              </el-card>
            </el-col>
          </el-row>
        </section>

        <section id="section4">
          <el-row :gutter="10" style="padding: 32px 0">
            <el-col :span="24">
              <el-row :gutter="10">
                <el-col :span="18">
                  <el-card>
                    <div
                      slot="header"
                      class="card-box"
                      style="display: flex; justify-content: space-between"
                    >
                      <span
                        ><i class="el-icon-collection"></i>
                        {{
                          salesGrade.join(" ") + " "
                        }}整体销售趋势（销售额/达成率）</span
                      >
                    </div>
                    <MinChart
                      :id="'echartTarget'"
                      :minchartData="echartDataMin"
                      height="410px"
                      width="100%"
                      @SetLineChartData="SetLineChartData"
                    />
                  </el-card>
                </el-col>
                <el-col :span="6">
                  <el-card>
                    <div
                      slot="header"
                      class="card-box"
                      style="display: flex; justify-content: space-between"
                    >
                      <span
                        ><i class="el-icon-collection"></i>
                        {{ salesGrade.join(" ") + " " }}店铺销售额占比</span
                      >
                    </div>
                    <PieChart
                      :id="'PieChart'"
                      height="410px"
                      :chartData="PieChartData"
                      @SetPieChartData="SetPieChartData"
                    />
                  </el-card>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </section>

        <section id="section10">
          <el-row :gutter="10" style="padding: 32px 0">
            <el-col :span="24">
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-card>
                    <div
                      slot="header"
                      class="card-box"
                      style="display: flex; justify-content: space-between"
                    >
                      <span
                        ><i class="el-icon-collection"></i>
                        {{ salesGrade.join(" ") + " " }}销售额 VS 客单价</span
                      >
                    </div>
                    <SelectChart
                      :id="'Amount'"
                      :minchartData="echartDataMin"
                      height="350px"
                      width="100%"
                    />
                  </el-card>
                </el-col>
                <el-col :span="12">
                  <el-card>
                    <div
                      slot="header"
                      class="card-box"
                      style="display: flex; justify-content: space-between"
                    >
                      <span
                        ><i class="el-icon-collection"></i>
                        {{ salesGrade.join(" ") + " " }}退款率 VS 加购率</span
                      >
                    </div>
                    <refundChart
                      :id="'refundChart'"
                      :minchartData="echartDataMin"
                      height="350px"
                      width="100%"
                    />
                  </el-card>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </section>

        <section id="section11">
          <el-row :gutter="10" style="padding: 32px 0">
            <el-col :span="24">
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-card>
                    <div
                      slot="header"
                      class="card-box"
                      style="display: flex; justify-content: space-between"
                    >
                      <span
                        ><i class="el-icon-collection"></i>
                        {{ salesGrade.join(" ") + " " }}访客数 VS 转化率</span
                      >
                    </div>
                    <percentChart
                      :id="'percentChart'"
                      :minchartData="echartDataMin"
                      height="350px"
                      width="100%"
                    />
                  </el-card>
                </el-col>
                <el-col :span="12">
                  <el-card>
                    <div
                      slot="header"
                      class="card-box"
                      style="display: flex; justify-content: space-between"
                    >
                      <span
                        ><i class="el-icon-collection"></i>
                        {{ salesGrade.join(" ") + " " }}获客成本 VS uv价值</span
                      >
                    </div>
                    <uvChart
                      :id="'uvChart'"
                      :minchartData="echartDataMin"
                      height="350px"
                      width="100%"
                    />
                  </el-card>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </section>

        <section id="section12">
          <el-row :gutter="10" style="padding: 32px 0">
            <el-col :span="12">
              <el-card>
                <div
                  slot="header"
                  class="card-box"
                  style="display: flex; justify-content: space-between"
                >
                  <span
                    ><i class="el-icon-collection"></i>
                    {{ salesGrade.join(" ") + " " }}平台访客转化</span
                  >
                </div>
                <!-- <funnelWeek
                  :id="'funnelYearList'"
                  :chartData="funnelYearList"
                /> -->
                <funnelDate
                  :id="'funnelYearList'"
                  :chartData="funnelYearList"
                />
              </el-card>
            </el-col>
            <el-col :span="12">
              <el-card>
                <div
                  slot="header"
                  class="card-box"
                  style="display: flex; justify-content: space-between"
                >
                  <span
                    ><i class="el-icon-collection"></i>
                    {{ salesGrade.join(" ") + " " }}付费转化分析</span
                  >
                </div>
                <funnelDate
                  :id="'funnelmarketingList'"
                  :chartData="funnelmarketingList"
                />
                <!-- <funnelWeek
              
                  :id="'funnelmarketingList'"
                  :chartData="funnelmarketingList"
                /> -->
              </el-card>
            </el-col>
          </el-row>
        </section>

        <section id="section5">
          <el-row style="background: #fff; margin-bottom: 32px; display: none">
            <!-- <h4
          style="
            font-weight: 600;
            color: #666;
            margin-left: 5px;
            margin-top: 25px;
          "
        > </h4>-->
            <el-card>
              <div
                slot="header"
                class="card-box"
                style="display: flex; justify-content: space-between"
              >
                <span>
                  <i class="el-icon-s-data" style="margin-right: 5px" />{{
                    salesGrade.join(" ") + " "
                  }}
                  <!-- <span style="margin-right: 5px">{{
                queryParams.dataDate
                  ? queryParams.dataDate
                  : queryParams.dataYear + "-" + queryParams.dataMonth
              }}</span
              > -->
                  品牌销售额
                </span>
                <span></span>
              </div>

              <el-col :span="12">
                <!-- :minchartData="echartDataMin"
                height="410px"
                width="100%"
                @SetLineChartData="SetLineChartData" -->
                <el-card>
                  <PieChart
                    :id="'className'"
                    :chartData="PieChartData"
                    @SetPieChartData="SetPieChartData"
                  />
                </el-card>
              </el-col>
              <el-col :span="12">
                <el-card
                  ><ve-bar
                    :settings="{
                      label: {
                        show: true,
                        position: 'top',
                        formatter: '{c}%',
                      },
                    }"
                    :data="barChartData"
                    style="height: 350px"
                    :extend="{ series: { barWidth: 15 } }"
                  ></ve-bar>
                </el-card>
              </el-col>
            </el-card>
          </el-row>
        </section>
      </el-tab-pane>

      <el-tab-pane label="商品监控" name="1">
        <!-- <section id="section6" style="margin-top: 32px"> -->
        <Shop v-if="activeName == 1" :query="query" />
        <!-- </section> -->
      </el-tab-pane>
    </el-tabs>
    <!-- <section id="section7">
      <el-row :gutter="10" style="padding: 32px 0">
        <el-col :span="17">
          <el-card>
            <div slot="header">
              <span><i class="el-icon-collection"></i> 店铺库存排行</span>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </section>

    <section id="section8">
      <el-row :gutter="10">
        <el-col :span="10">
          <el-card style="height: calc(100vh - 125px)">
            <div slot="header">
              <span><i class="el-icon-collection"></i> 销售地区Top20</span>
            </div>
          </el-card>
        </el-col>

        <el-col :span="14">
          <el-card style="height: calc(100vh - 125px)">
            <div ref="platform" style="width: 1100px; height: 960px"></div>
          </el-card>
        </el-col>
      </el-row>
    </section> -->
  </div>
</template>

<script>
import {
  selectOperationsSummary,
  selectChannelConversion,
  selectTXSaleTargetStatistics,
  selectShopSaleAmountRatio,
} from "@/api/sale/BiTbSaleDwd";
import //
"@/api/sale/BiSaleMarketingDwd";
import {
  //饼图
  brandSaleAmount,
  //环比
  channelSaleAmountYoy,
} from "@/api/sale/BiSaleAmount";
import { getCache } from "@/api/monitor/cache";
// import echarts from "echarts";
import * as echarts from "echarts/lib/echarts.js";
require("echarts/extension/bmap/bmap");
import "echarts/map/js/china.js"; //引入中国地图数据
import city from "echarts/map/json/china-cities.json";
import date from "./day/date.vue";
import chartDataI from "./components/chartDataI";
import chartData from "./components/chartData";

import refundChart from "@/views/sale/taobao/Chart/refundChart.vue";
import uvChart from "@/views/sale/taobao/Chart/uvChart.vue";
import percentChart from "@/views/sale/taobao/Chart/percentChart.vue";
import SelectChart from "@/views/sale/taobao/Chart/SelectChart.vue";
import MinChart from "@/views/sale/taobao/Chart/MinChart.vue";
import MixChart from "./Chart/MixChart.vue";
// import funnel from "./Chart/funnel.vue";
import funnelDate from "@/views/sale/taobao/Chart/funnelDate.vue";
import funnelWeek from "@/views/sale/taobao/Chart/funnelWeek.vue";
import timeSearch from "./day/day.vue";
import exhaustionDay from "./day/exhaustionDay.vue";
// import waterLevelChart from "./waterLevelChart";
import progressMonthly from "./components/progressMonthly";
import progressYear from "./components/progressYear";
import card from "./Chart/card.vue";

// import channel from "@/views/sale/channel/index.vue";
import PanelGroup from "./components/PanelGroup";
import PanelGroupI from "./components/PanelGroupI";
import PanelGroupII from "./components/PanelGroupII";
import PanelGroupDate from "./components/PanelGroupDate";
import PanelGroupWeek from "./components/PanelGroupWeek";
// import LineChart from './components/LineChart'
import chartDataRaddar from "./components/chartDataRaddar";
import RaddarChart from "./components/RaddarChart";
import PieChart from "./components/PieChart";
import BarChart from "./components/BarChart";

import Shop from "./Shop/index.vue";
import { listBrandChannelShop, listAll } from "@/api/chart/brandChannelShop";

const lineChartData = {};

export default {
  name: "Admin",
  dicts: [
    "sys_product_item",
    "sys_product_secondary",
    "sys_product_cycle",
    "sys_product_pl",
  ],
  components: {
    chartDataRaddar,
    // GithubCorner,
    PanelGroup,
    PanelGroupI,
    PanelGroupII,
    PanelGroupDate,
    PanelGroupWeek,
    funnelDate,
    funnelWeek,
    card,
    progressMonthly,
    progressYear,
    // LineChart,

    // RaddarChart,
    PieChart,
    BarChart,

    chartData,
    chartDataI,
    MinChart,
    SelectChart,
    percentChart,
    uvChart,
    refundChart,
    MixChart,
    // TransactionTable,
    // TodoList,
    // BoxCard
    timeSearch,
    exhaustionDay,
    date,
    // channel,
    // funnel,
    Shop,
  },
  data() {
    return {
      activeName: 0,
      funnelmarketingList: [],
      funnelYearList: [],
      funnelDateList: [],
      funnelWeekList: [],
      //BI指标数据
      biNumberItem: {},
      weekList: {},
      dateList: {},
      query: {},
      // 店铺
      cascadeList: [],
      // , "天猫", "vfu运动旗舰店"
      salesGrade: [],
      typeArr: [
        { value: "month", label: "MTD" },
        { value: "quarterly", label: "QTD" },
        { value: "year", label: "YTD" },
      ],
      dateType: "month",
      //
      barChartData: {
        columns: [],
        rows: [],
      },
      //环比
      PieData: [],
      //趋势图
      skcitemData: [],
      //饼图
      PieChartData: {
        // order: {
        xData: [],
        female: [],
        // male: [],
        // average: [],
      },
      echartDataMin: {
        // order: {
        xData: [],
        female: [],
        male: [],
        average: [],
      },
      echartData: {
        value: 0,
        name: "",
        bg: "",
      },
      echartDataquarterly: {
        value: 0,
        name: "",
        bg: "",
      },
      echartDatamonthly: {
        value: 0,
        name: "",
        bg: "",
      },

      //品类属性
      itemType: [],
      //价格带
      list: [],
      //多选品类
      formData: {
        libraryIdList: [{ id: "" }],
      },
      libraryOptions: [], // 库存名称列表

      //雷达图
      echartDataRaddar: [],
      //总览数据
      itemData: {},
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        // pageNum: 1,
        // pageSize: 10,
        // property: "salesAmount",
        // firstLevelList: null,
        // secondLevelList: null,
        // threeLevelList: null,
      },
      //商品排行
      ItemDateList: [],
      //产品视角
      productView: "一级",

      //锚点
      sections: document.querySelectorAll("section"),
      activeSection: null,
      active: null,
      scrollTimer: null,
      //地区前20
      TopSallist: [],
      tableHeight: window.innerHeight - 175,
      pageHeight: window.innerHeight - 280,
      itemHeight: window.innerHeight - 680,
      shopListHeight: window.innerHeight - 570,

      biNumberSku: [],
      //时间控件
      timeObj: {},
      //客单价
      biNumberOfItem: "",

      //时间控件
      valueTime: new Date(new Date().setDate(new Date().getDate() - 1)),
      groupType: "date",

      highlighted: ["销售金额", "退款金额", "净销售额"], // 初始化时，前两个元素高亮

      //传递数据
      // echartData: {
      //   columns: ["支付日期", "销售金额", "退款金额", "净销售额"],
      //   rows: [],
      // },
      highlightedSku: ["库存总金额", "产品库存总金额", "配件库存总金额"], // 初始化时，前两个元素高亮

      //Sku传递数据
      echartDataSku: {
        columns: ["支付日期", "销售目标", "销售额", "达成率"],
        rows: [],
      },
      //时间
      dayActive: 15,
      monthActive: false,
      timeArr: [
        // { value: "2", label: "昨天" },
        { value: "15", label: "最近15天" },
        // { value: "30", label: "最近30天" },
        { value: "365", label: "月" },
        { value: "1", label: "日" },
      ],
      timeGap: { startTime: "", endTime: "" },

      loading: false,
      //店铺名称
      shopName: "",
      mapData: [],
      lineChartData: lineChartData.newVisitis,
    };
  },
  created() {
    this.getList();

    // this.handleChangeTime()
    /** 查询品牌渠道店铺关系列表 */
    this.getdataSourceList();
    // this.openLoading();
  },
  filters: {
    state1(string) {
      if (string == "month") {
        return "本月";
      }
      if (string == "quarterly") {
        return "本季";
      }
      if (string == "year") {
        return "本年";
      }
      // if (int == 2) { return "审批通过" };
    },
  },
  // mounted() {
  //   this.$store.dispatch("app/toggleSideBarHide", fa);
  // },
  watch: {
    salesGrade: {
      handler: function (newnew, oldold) {
        this.query = {
          salesGrade: this.salesGrade.join(","),

          dateType: this.dateType,
        };
        if (!this.query.salesGrade) {
          return;
        }
        this.getselectSaleSingle("date");
        this.getselectSaleSingle("week");
        this.getselectSaleSingle(this.dateType);
        this.getselectSaleTargetStatistics();
        this.getskuBySkcSaleList();
        this.getselectChannelConversion(this.query);
      },
      deep: true,
      immediate: true,
    },
    dateType: {
      handler: function (newnew, oldold) {
        console.log(JSON.stringify(newnew));
        this.query = {
          salesGrade: this.salesGrade.join(","),
          // brand: this.salesGrade[0],
          // channel: this.salesGrade[1],
          dateType: this.dateType,
        };
        if (!this.query.salesGrade) {
          return;
        }
        this.getselectSaleSingle(this.dateType);

        this.getselectSaleTargetStatistics();
        this.getskuBySkcSaleList();
        this.getselectChannelConversion(this.query);
      },
      deep: true,
      immediate: true,
    },
    // monthActive: {
    //   handler: function (newnew, oldold) {

    //     if (!this.timeGap.endTime) {
    //       return;
    //     }
    //     let obj = {};
    //     if (this.monthActive) {
    //       obj = {
    //         dateType: "month",
    //         salesGrade: this.salesGrade.join(","),
    //       };
    //     } else {
    //       obj = {
    //         dateType: "date",
    //         ...this.timeGap,
    //         salesGrade: this.salesGrade.join(","),
    //       };
    //     }
    //
    //   },
    //   deep: true,
    //   immediate: true,
    // },
  },
  mounted() {
    window.addEventListener("scroll", this.startScrollTimer);
  },
  beforeDestroy() {
    window.removeEventListener("scroll", this.startScrollTimer);
  },

  methods: {
    handleClick(tab, event) {},
    //指标点击回传
    handleSetLineChartData(type) {},

    getselectSaleTargetStatistics() {
      selectTXSaleTargetStatistics(this.query).then((response) => {
        // this.queryParams = {};
        // this.queryParams.salesGrade = this.salesGrade;
        // // this.queryParams.channel = this.salesGrade[1];
        // this.queryParams.dataYear = response[response.length - 1].dataYear;
        // this.queryParams.dataMonth = response[response.length - 1].dataMonth;
        // if (response[response.length - 1].dataDate) {
        //   this.queryParams.dataDate = response[response.length - 1].dataDate;
        // }

        response.forEach((item, index) => {
          item.id = index;
        });
        this.skcitemData = response;
        this.echartDataMin.xData = response.map((item) =>
          item.dataDate ? item.dataDate : item.dataMonth
        );
        //销售目标
        this.echartDataMin.female = response.map((item) =>
          item.saleTarget ? item.saleTarget : null
        );
        //销售额
        this.echartDataMin.male = response.map((item) => item.saleAmount);
        //达成率
        this.echartDataMin.average = response.map(
          (item) => item.completionRate
        );
        //客单价
        this.echartDataMin.avgOrderValue = response.map(
          (item) => item.avgOrderValue
        );
        //访客数
        this.echartDataMin.visitorCount = response.map(
          (item) => item.visitorCount
        );
        //转化率
        this.echartDataMin.paymentConversionRate = response.map(
          (item) => item.paymentConversionRate
        );
        //获客成本
        this.echartDataMin.customerAcquisitionCost = response.map(
          (item) => item.customerAcquisitionCost
        );
        //uv价值
        this.echartDataMin.uvValue = response.map((item) => item.uvValue);
        //退款率
        this.echartDataMin.refundRate = response.map((item) => item.refundRate);
        //加购率
        this.echartDataMin.cartRate = response.map((item) => item.cartRate);
      });
    },
    //skc图表点击
    SetLineChartData(index) {
      return;
      console.log(index);
      this.skcitemData.forEach((item) => {
        if (index == item.id) {
          console.log(JSON.stringify(item));
          // let obj = {
          //   dataYear: item.dataYear,
          //   dataMonth: item.dataMonth,
          //   company: this.salesGrade[0],
          // };
          this.queryParams = {};
          if (!item.dataDate) {
            this.queryParams.dataYear = item.dataYear;
            this.queryParams.dataMonth = item.dataMonth;
          } else {
            this.queryParams.dataDate = item.dataDate;
          }

          this.queryParams.salesGrade = this.salesGrade;
        }
      });
    },
    //饼图点击
    SetPieChartData(index) {
      this.PieData.forEach((item) => {
        if (index == item.id) {
          // let obj = {
          //   dataYear: item.dataYear,
          //   dataMonth: item.dataMonth,
          //   company: this.salesGrade[0],
          // };
          // this.queryParams.dataYear = item.dataYear;
          // this.queryParams.dataMonth = item.dataMonth;
          // this.queryParams.company = this.salesGrade[0];

          this.getchannelSaleAmountYoy(item.brand);
        }
      });
    },
    //环比
    getchannelSaleAmountYoy(brand) {
      let obj = {
        label: "channel",
        brand: brand,
        ...this.queryParams,
      };

      channelSaleAmountYoy(obj).then((response) => {
        // this.barChartData.columns = ["gpuType", "val1", "val2"];
        this.barChartData = {
          columns: [],
          rows: [],
        };
        this.barChartData.columns.push("渠道", "销售增长率");
        response.forEach((item) => {
          this.barChartData.rows.push({
            渠道: item.channel,
            销售增长率: item.saleAmountYoy,
          });
        });
      });
    },
    //饼图
    getskuBySkcSaleList() {
      // if (this.query.dateType == "month") {
      // this.queryParams.dateType = "date";
      // } else {
      //   this.queryParams.dateType = "month";
      // }

      selectShopSaleAmountRatio(this.query).then((response) => {
        console.log(JSON.stringify(response));
        if (response.length < 1) {
          return;
        }

        response.forEach((item, index) => {
          item.id = index;
        });
        // this.skcitemData = response;
        this.PieData = response;
        // this.getchannelSaleAmountYoy(this.PieData[0].shopName);
        if (response) {
          let row = [];
          response.forEach((item) => {
            row.push({
              value: item.saleAmount,
              name: item.shopName,
            });
          });
          // this.PieChartData.female
          this.PieChartData.xData = response.map((item) => item.shopName);
          this.PieChartData.female = row;
        }
      });
    },
    getselectChannelConversion(obj) {
      selectChannelConversion(obj).then((response) => {
        if (response) {
          if (obj.value == "date") {
            let row = [];
            row.push({
              name: "平台总访客数",

              value: response.visitors,
              yoy: response.visitorsYoy,
            });
            row.push({
              name: "收藏加购人数",
              value: response.collectAddPurchasesPeoNum,
              yoy: response.collectAddPurchasesPeoNumYoy,
              twoname: "加购率",
              twoyoy: response.addPurchasesRate,
            });
            row.push({
              name: "支付人数",
              value: response.payBuyers,
              yoy: response.payBuyersYoy,
              twoname: "支付转化率",
              twoyoy: response.payConversionRate,
            });
            this.funnelDateList = row;
          } else if (obj.value == "week") {
            let row = [];
            row.push({
              name: "平台总访客数",

              value: response.visitors,
              yoy: response.visitorsYoy,
            });
            row.push({
              name: "收藏加购人数",
              value: response.collectAddPurchasesPeoNum,
              yoy: response.collectAddPurchasesPeoNumYoy,
              twoname: "加购率",
              twoyoy: response.addPurchasesRate,
            });
            row.push({
              name: "支付人数",
              value: response.payBuyers,
              yoy: response.payBuyersYoy,
              twoname: "支付转化率",
              twoyoy: response.payConversionRate,
            });
            this.funnelWeekList = row;
          } else {
            let row = [];
            row.push({
              name: "平台总访客数",

              value: response.visitors,
              yoy: response.visitorsYoy,
            });
            row.push({
              name: "收藏加购人数",
              value: response.collectAddPurchasesPeoNum,
              yoy: response.collectAddPurchasesPeoNumYoy,
              twoname: "加购率",
              twoyoy: response.addPurchasesRate,
            });
            row.push({
              name: "支付人数",
              value: response.payBuyers,
              yoy: response.payBuyersYoy,
              twoname: "支付转化率",
              twoyoy: response.payConversionRate,
            });
            this.funnelYearList = row;

            let list = [];

            list.push({
              name: "推广付费点击量",

              value: response.marketingClick,
              yoy: response.marketingclickYoy,
            });
            list.push({
              name: "推广收藏加购人数",
              value: response.marketingcartFavorite,
              yoy: response.marketingCartFavoriteYoy,
              twoname: "加购率",
              twoyoy: response.marketingCartRate,
            });
            list.push({
              name: "推广支付人数",
              value: response.marketingPaidcustomers,
              yoy: response.marketingPaidCustomersYoy,
              twoname: "支付转化率",
              twoyoy: response.marketingPayConversionRate,
            });
            this.funnelmarketingList = list;
          }
        }
      });
    },
    //销售指标
    getselectSaleSingle(value) {
      let obj = {
        salesGrade: this.salesGrade.join(","),
        //   brand: this.salesGrade[0],
        //   channel: this.salesGrade[1],
        dateType: value,
      };
      selectOperationsSummary(obj).then((response) => {
        if (response) {
          if (value == "date") {
            this.dateList = response;
            this.getselectChannelConversion(obj);
          } else if (value == "week") {
            this.weekList = response;
            this.getselectChannelConversion(obj);
          } else {
            this.biNumberItem = response;
          }
        }
      });
      return;
      // if (value != "date" || value != "week") {
      //   return;
      // }
      selectChannelConversion(obj).then((response) => {
        if (response) {
          if (value == "date") {
            this.funnelDateList = [
              {
                name: "平台总访客数",
                value: response.visitors,
                yoy: response.visitorsYoy,
                twoname: "",
                twoyoy: "",
              },
              {
                name: "收藏加购人数",
                value: response.collectAddPurchasesPeoNum,
                yoy: response.collectAddPurchasesPeoNumYoy,
                twoname: "加购率",
                twoyoy: response.addPurchasesRate,
              },
              {
                name: "支付人数",
                value: response.payBuyers,
                yoy: response.payBuyersYoy,
                twoname: "支付转化率",
                twoyoy: response.payConversionRate,
              },
            ];
          } else if (value == "week") {
            this.funnelWeekList = [
              {
                name: "平台总访客数",
                value: response.visitors,
                yoy: response.visitorsYoy,
                twoname: "",
                twoyoy: "",
              },
              {
                name: "收藏加购人数",
                value: response.collectAddPurchasesPeoNum,
                yoy: response.collectAddPurchasesPeoNumYoy,
                twoname: "加购率",
                twoyoy: response.addPurchasesRate,
              },
              {
                name: "支付人数",
                value: response.payBuyers,
                yoy: response.payBuyersYoy,
                twoname: "支付转化率",
                twoyoy: response.payConversionRate,
              },
            ];
          }
        }
      });
    },
    //店铺控件
    handleChange(val) {
      return;
      // console.log(JSON.stringify(val));
      // // let obj = { salesGrade: this.this.salesGrade.join(","), ...this.timeObj };
      // let obj = { salesGrade: this.this.salesGrade.join(",") };
      // console.log(JSON.stringify(obj));

      // localStorage.removeItem("result");
      // // localStorage.setItem("result", JSON.stringify(obj));

      // if (!obj.endTime) {
      //   return;
      // } else {
      //   //销售指标

      //   //渠道库存Top
      //   this.channelInventoryTop(obj);
      //   //店铺库存Top
      //   this.shopInventoryTop(obj);
      //   //曲线
      //   this.getechartChannelData(obj);

      //   //渠道SaleTop
      //   this.getchannelSaleTop(obj);
      //   //店铺SaleTop
      //   this.getshopSaleTop(obj);
      //   //商品排行Top
      //   this.changeView();
      // }
      // let param = {
      //   dataSource: this.salesGrade,
      //   startTime: this.dateFormat(this.timeObj.startTime),
      //   endTime: this.dateFormat(this.timeObj.endTime),

      // };
      // console.log(JSON.stringify(param));
      // if (!param.endTime) {
      //   return;
      // } else {
      //   // this.getechartChannelData(obj)
      //   this.getnumberOfItem(param);
      //   this.getTopSal(param);
      // }
    },
    //选完时间后发请求
    handleChangeTime(timeObj) {
      // console.log(type)
      // console.log(timeObj)
      // TODO
      this.timeObj = timeObj;
      if (this.salesGrade.length <= 0) {
        return;
      }
      return;
      let param = {
        dataSource: this.salesGrade,
        startTime: this.dateFormat(timeObj.startTime),
        endTime: this.dateFormat(timeObj.endTime),
      };
      console.log(JSON.stringify(param));
      if (!param.endTime) {
        return;
      } else {
        // this.getechartChannelData(obj)
        //客件数
        this.getnumberOfItem(param);
        //地区Top20
        this.getTopSal(param);
      }
      console.log(JSON.stringify(this.timeObj));

      let obj = { salesGrade: this.this.salesGrade.join(",") };

      console.log(JSON.stringify(obj));

      localStorage.removeItem("result");
      localStorage.setItem("result", JSON.stringify(obj));

      if (!obj.endTime) {
        return;
      } else {
        //渠道库存Top
        this.channelInventoryTop(obj);
        //店铺库存Top
        this.shopInventoryTop(obj);
        //曲线
        this.getechartChannelData(obj);

        //渠道SaleTop
        this.getchannelSaleTop(obj);
        //店铺SaleTop
        this.getshopSaleTop(obj);
        //商品排行Top
        this.changeView();
      }
    },
    //分页
    //售罄时间定义
    changePage() {},
    //视图角度
    changeView(val) {},

    // 时间格式转换
    dateFormat(date) {
      date = new Date(date);
      let Y = date.getFullYear() + "-";
      let M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      let D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate() + "";
      return Y + M + D;
    },
    /** 查询品牌渠道店铺关系列表 */
    getdataSourceList() {
      listAll().then((response) => {
        let result = this.transformData(response);
        // this.salesGrade = [result[0].label, result[0].children[0].label];
        this.salesGrade = [result[0].label];
        this.cascadeList = result;
      });
    },
    //店铺渠道品牌转换

    transformData(data) {
      let result = [];

      data.forEach((item) => {
        let brand = item.brand;
        // let channel = item.brand;
        // let shopName = item.shopName;

        // 如果brand在结果数组中不存在，则创建一个新的数组
        let brandIndex = result.findIndex(
          (brandObj) => brandObj.label === brand
        );
        if (brandIndex === -1) {
          result.push({
            label: brand,
            value: brand,
            // children: [],
          });
          brandIndex = result.length - 1;
        }

        // 如果channel在当前brand的children数组中不存在，则创建一个新的数组
        // let channelIndex = result[brandIndex].children.findIndex(
        //   (channelObj) => channelObj.label === channel
        // );
        // if (channelIndex === -1) {
        //   result[brandIndex].children.push({
        //     label: channel,
        //     value: channel,
        //     // children: [],
        //   });
        //   channelIndex = result[brandIndex].children.length - 1;
        // }

        // 如果shopName在当前channel的children数组中不存在，则创建一个新的数组
        // let shopIndex = result[brandIndex].children[
        //   channelIndex
        // ].children.findIndex((shopObj) => shopObj.label === shopName);
        // if (shopIndex === -1) {
        //   result[brandIndex].children[channelIndex].children.push({
        //     label: shopName,
        //     value: shopName,
        //     // children: []
        //   });
        // }
      });

      return result;
    },
    //锚点
    scrollToSection(index) {
      const target = this.sections[index];
      // console.log(JSON.stringify(index));
      //     return
      this.active = index;
      if (target) {
        this.$nextTick(() => {
          target.scrollIntoView({ behavior: "smooth" });
          this.activeSection = target;
        });
      }
    },
    //锚点
    startScrollTimer() {
      this.scrollTimer = setInterval(() => {
        const currentSection = document.querySelector("section[data-active]");
        if (currentSection !== this.activeSection) {
          this.activeSection = currentSection;
        } else {
          clearInterval(this.scrollTimer);
        }
      }, 100); // 每100毫秒检查一次滚动位置是否变化
    },
    //锚点高亮
    isActiveSection(sectionId) {
      // 检查当前导航项是否处于高亮状态
      return this.active === sectionId;
    },
    /** 查缓存询信息 */
    getList() {},
    // 打开加载层
    openLoading() {
      this.$modal.loading("正在加载分析销售监控数据，请稍候！");
    },
    //地区Top20
    getTopSal(param) {},
  },
};
</script>

<style lang="scss" scoped>
.el-tabs--card {
  height: calc(100vh - 110px);
  /* overflow-y: auto; */
}
.el-tab-pane {
  height: calc(100vh - 110px);
  overflow-y: auto;
}
.nomargin {
  display: flex;
  justify-content: center;
  align-items: center;
}
.content {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}
/* 移除默认的列表样式 */
ul {
  margin-top: 0.4%;
  list-style-type: none;
  /* 设置弹性布局，使列表项横向排列 */
  display: flex;
  /* 添加一些内边距和背景颜色 */
  // padding: 10px;
  margin-right: 10px;
  /* 设置边框和圆角 */
  // border: 1px solid #ddd;
  border-radius: 5px;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
}

/* 设置列表项样式 */
li {
  /* 添加一些内边距和右边距 */
  // padding: 10px;
  margin-right: 10px;
  /* 设置链接文本样式 */
  font-size: 15px;
  color: #bbb;
  text-decoration: none;
}

li.active a {
  // color: #f00;
  /* 高亮颜色 */
  color: #fff;
  background-color: #40c9c6;
}

// section {
//   margin-top: 60px;
// }

.dashboard-editor-container {
  // padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
// .train-tree-cascader {
//   height: 500px !important;
// }

// .el-scrollbar__wrap {
//   overflow: initial !important;
// }
</style>
public class BiOperationsSummary {

    /** 销售额 */
    @Excel(name = "销售额")
    private Double saleAmount;
    private Double saleAmountChain;//环比
    private Double saleAmountYoy;//同比

    /** 退款金额 */
    @Excel(name = "退款金额")
    private Double returnAmount;
    private Double returnAmountChain;//环比
    private Double returnAmountYoy;//同比

    /** 退款率 */
    @Excel(name = "退款率")
    private Double returnAmountRate;
    private Double returnAmountRateChain;//环比
    private Double returnAmountRateYoy;//同比

    /** 净销售额 */
    @Excel(name = "净销售额")
    private Double netSalesAmount;
    private Double netSalesAmountChain;//环比
    private Double netSalesAmountYoy;//同比

    /** 营销花费 */
    @Excel(name = "营销花费")
    private Double marketingAmount;
    private Double marketingAmountChain;//环比
    private Double marketingAmountYoy;//同比

    /** 下单数 */
    @Excel(name = "下单数")
    private Integer ordersNumber;
    private Double ordersNumberChain;//环比
    private Double ordersNumberYoy;//同比

    /** 目标金额（万） */
    @Excel(name = "目标金额")
    private Double salesTarget;

    /** 目标达成率 */
    @Excel(name = "目标达成率")
    private Double targetCompletionRate; // 目标达成率;

    /** 店铺运营数 */
    @Excel(name = "店铺运营数")
    private Integer shopCount; // 目标达成率;

    //商品销售成本
    @Excel(name = "商品销售成本")
    private Double saleCostPro;
    private Double saleCostProChain;//环比
    private Double saleCostProYoy;//同比


    /** 客单价 */
    @Excel(name = "客单价")
    private Double customerUnitPrice;
    private Double customerUnitPriceChain;//环比
    private Double customerUnitPriceYoy;//同比


    /** 预计达成金额 */
    @Excel(name = "预计达成金额")
    private Double estimateCompletionAmount;

    /*赠品占比**/
    @Excel(name = "赠品占比")
    private Double complimentaryRatio;
    private Double complimentaryRatioChain;//环比
    private Double complimentaryRatioYoy;//同比

    /*ROI**/
    @Excel(name = "ROI")
    private Double roi;
    private Double roiChain;//环比
    private Double roiYoy;//同比

    /*总访客数**/
    @Excel(name = "总访客数")
    private Integer visitors;
    private Double visitorsChain;//环比
    private Double visitorsYoy;//同比

    /*获客成本**/
    @Excel(name = "获客成本")
    private Double customerAcquisitionCost;
    private Double customerAcquisitionCostChain;//环比
    private Double customerAcquisitionCostYoy;//同比

    /*老客数**/
    @Excel(name = "老客数")
    private Integer payOldBuyers;
    private Double payOldBuyersChain;//环比
    private Double payOldBuyersYoy;//同比

    /*新客数**/
    @Excel(name = "新客数")
    private Integer payNewBuyers;
    private Double payNewBuyersChain;//环比
    private Double payNewBuyersYoy;//同比

    /*老客占比**/
    @Excel(name = "老客占比")
    private Double oldBuyersRatio;
    private Double oldBuyersRatioChain;//环比
    private Double oldBuyersRatioYoy;//同比

    /*新客占比**/
    @Excel(name = "新客占比")
    private Double newBuyersRatio;
    private Double newBuyersRatioChain;//环比
    private Double newBuyersRatioYoy;//同比

    /** 年 */
    @Excel(name = "年")
    private Integer dataYear;

    /** 季 */
    @Excel(name = "季")
    private Integer dataQuarter;

    /** 月 */
    @Excel(name = "月")
    private Integer dataMonth;

    /** 周 */
    @Excel(name = "周")
    private Integer dataWeek;

}
/** 营销付费点击量 */
@Excel(name ="营销付费点击量")private Integer marketingClick;private Double marketingclickYoy;//同比
/** 营销收藏加购人数 */
@Excel(name ="营销收藏加购人数")private Integer marketingcartFavorite;private Double marketingCartFavoriteYoy;//同比
/** 营銷加购人数 */
@Excel(name =“营销加购人数")private Integer marketingCartcount;private Double marketingcartcountYoy://同比
/** 营銷收加购率 */@Excel(name =“营销收藏加购率")private Integer marketingCartFavoriteRate
/** 营销加购率 */@Excel(name =“营销加购率")
private Integer marketingCartRate;
/** 营销支付人数 */@Excel(name ="营销支付人数")private Integer marketingPaidcustomers;private Double marketingPaidCustomersYoy;//同比
/** 营销支付转化率 */
@Excel(name =“营销支付转化率")
private Double marketingPayConversionRate;